<?php
include_once("model/Model.php");
include_once("Classes/logging.php");

class Controller {
	public $model;
	
	public function __construct()  
    {  
	    $this->model = new Model();
		
    } 
	
	public function invoke()
	{
	//runtimelog("invoke");
		session_start(); 
	if(!isset($_SESSION['id'])){
	 	include 'view/login.php';
	 }else{
		include 'view/viewhead.php';
		$currentUser=$this->model->getAccount($_SESSION['username']);
		$allOrganizations=$this->model->getOrganizations('all');
		$this->model->refresh($_SESSION['id']);
		include 'view/viewbody.php';
		switch ($_GET['page']) {
	    case 'intro':
	        include 'view/intro.php';
	        break;
		case 'notice':
	        include 'view/notice.php';
	        break;
	    case 'error':
	        break;
		case 'contact_user':
			$allUsers=$this->model->getAllAccount();
			include 'view/contact_user.php';
	        break;
		 case 'home':
	        include 'view/home.php';
	        break;
	    case 'current_user':
			include 'view/current_user.php';
	        break;
	    case 'manage_users':
			$sql="SELECT `id`, `name`,
				  IF(( now()-`refresh_time`)<500,1,0) as online 
				  FROM `user`
				  WHERE `id`>0";
			$result=mysql_query($sql);
			//=$this->model->storedProcedure('_g_online_users',array());
			$online=array();
			while($row = mysql_fetch_array($result))
		      {
		      	if($row['online']==1){
		      		array_push($online,$row['id']);
		      	}
		     }
			$allUsers=$this->model->getAllAccount();
			include 'view/manage_users.php';
	        break;
	    case 'manage_items':
			include 'view/displayTable.php';
			$allItems=$this->model->getAllItem();
			$table=itemToTable($allItems,'item','现有产品列表:','button');
			include 'view/manage_items.php';
	        break;
	    case 'manage_show':
			include 'view/displayTable.php';
			$allItems=$this->model->getAllItem();
			$table=itemToTable($allItems,'item','现有产品列表:','button');
			include 'view/manage_show.php';
	        break;
	    case 'manage_transaction':
			include 'view/displayTable.php';
	        $condition="";
			if (!isset($_POST['scan_code'])||strlen($_POST['scan_code'])!=14){
				$scan_code=NULL;
			}else{
				$scan_code=$_POST['scan_code'];
				$condition.="  条形码为:".$scan_code;
			}
			if (!isset($_POST['organization'])||strlen($_POST['organization'])==0){
				$organizaiton=NULL;
			}else{
				$organizaiton=$_POST['organization'];
				$condition.="  机构代号:".$organization;
			}
			if (!isset($_POST['actions'])||strlen($_POST['actions'])==0){
				
				$actions=NULL;
			}else{
				$actions=$_POST['actions'];
				$condition.="  类型:‘".$actions."’";
			}
			
            if (!isset($_POST['fromYear'])||strlen($_POST['fromYear'])!=4&&strlen($_POST['fromMonth'])!=2&&strlen($_POST['fromDate'])!=2){
				$start=NULL;
			}else{
				$start=$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate'];
				$condition.="  时间从:".$start;
				
			}
			if (!isset($_POST['toYear'])||strlen($_POST['toYear'])!=4&&strlen($_POST['toMonth'])!=2&&strlen($_POST['toDate'])!=2){
				$end=NULL;
			}else{
				$end=$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate'];
				$condition.="  时间至:".$end;
				
			}
			
			if (!isset($_POST['minNum'])||strlen($_POST['minNum'])==0||!is_numeric($_POST['minNum'])){
				$minNum=NULL;
			}else{
				$minNum=$_POST['minNum'];
				$condition.="  数量下限:".$minNum;
			}
			if (!isset($_POST['maxNum'])||strlen($_POST['maxNum'])==0||!is_numeric($_POST['maxNum'])){
				$maxNum=NULL;
			}else{
				$maxNum=$_POST['maxNum'];
				$condition.="  数量上限:".$maxNum;
			}
			if($condition==""){
				$condition="无";
			}
            $confirm=array(0,1);
			$minimal=NULL;
			$maximal=NULL;
			$transactions=$this->model->getFinacialTransactions($actions,$organizaiton,$start,$end,$minimal,$maximal,$minNum,$maxNum,$scan_code,$confirm);
		  
		   $table=transactionToTable($transactions,'totaltransaction','有效操作记录','radio');
		   $message="物流记录搜索 得到(".count($transactions).")条记录 条件为：\n";
		
			include 'view/manage_transaction.php';
	        break;
	    case 'manage_organizations':
			include 'view/displayTable.php';
			$table=organizatonsToTable($allOrganizations);
			
			include 'view/manage_organizations.php';
	        break;
	    case 'alter_organizations':
			$organization=$this->model->getOrganizations($_GET['id']);
			
			include 'view/alter_organizations.php';
	        break;
	    case 'alter_user':
			$user=$this->model->getAccountById($_GET['id']);
			include_once 'view/alter_user.php';
	        break;
	    case 'alter_item':
			$item=$this->model->getItem($_GET['scan_code']);
			include_once 'view/alter_item.php';
	        break;
	    case 'organization_stack':
			$allItems=$this->model->getAllItem();
			$organization=$this->model->getOrganizations($_GET['id']);
			include_once 'view/displayTable.php';
			$table=itemToTable($allItems,$organization->id,$organization->name,'radio');
			include 'view/organization_stack.php';
	        break;
	    case 'organization_return':
			$allItems=$this->model->getAllItem();
			include_once 'view/displayTable.php';
			$organization=$this->model->getOrganizations($_GET['id']);
			$table=itemToTable($allItems,$organization->id,'产品清单','checkbox');
			include 'view/organization_return.php';
	        break;
	    case 'organization_inventory':
			include 'view/displayTable.php';
           	$organization=$this->model->getOrganizations($_GET['id']);
		   	$condition="";
			if (!isset($_POST['scan_code'])||strlen($_POST['scan_code'])!=14){
				$scan_code=NULL;	
				
			}else{
				$scan_code=$_POST['scan_code'];
				$condition.="  条形码为:".$scan_code;
			}
			
			
			if (!isset($_POST['fromYear'])||strlen($_POST['fromYear'])!=4||strlen($_POST['fromMonth'])!=2||strlen($_POST['fromDate'])!=2){
				$start=NULL;
			}else{
				$start=$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate'];
				$condition.="  时间从:".$start;
				
			}
			if (!isset($_POST['toYear'])||strlen($_POST['toYear'])!=4||strlen($_POST['toMonth'])!=2||strlen($_POST['toDate'])!=2){
				$end=NULL;
			}else{
				$end=$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate'];
				$condition.="  时间至:".$end;
				
			}
			
			if (!isset($_POST['minNum'])||strlen($_POST['minNum'])==0||!is_numeric($_POST['minNum'])){
				$minNum=NULL;
			}else{
				$minNum=$_POST['minNum'];
				$condition.="  数量下限:".$minNum;
			}
			if (!isset($_POST['maxNum'])||strlen($_POST['maxNum'])==0||!is_numeric($_POST['maxNum'])){
				$maxNum=NULL;
			}else{
				$maxNum=$_POST['maxNum'];
				$condition.="  数量上限:".$maxNum;
			}
			if($condition==""){
				$condition="无";
			}
			$inventory=$this->model->getInventory($_GET['id'],$scan_code,$minNum,$maxNum,$start,$end);
		    $message="库存搜索 得到(".count($inventory).")条记录 条件为：\n";
			$table=inventoryToTable($inventory,$organization->id,$organization->name,NULL);
		  
		   	$organization->setInventory($inventory);
		   	$allUsers=$this->model->getAllAccount();
		   	$authorized=array();
		   	foreach($allUsers as $user){
		   		if($user->authrized($_GET['id'])==1){
		   		//echo $user->name.": ".$user->getAuthority()."<br>";
		   		array_push($authorized,$user);
				}
		   	}
		   $organization->setAuthorized($authorized);
			include 'view/organization_inventory.php';
	        break;
	    case 'organization_transaction':
			include 'view/displayTable.php';
	        $condition="";
			if (strlen($_POST['scan_code'])!=14){
				$scan_code=NULL;
			}else{
				$scan_code=$_POST['scan_code'];
				$condition.="  条形码为:".$scan_code;
			}
			if (strlen($_POST['actions'])==0){
				
				$actions=NULL;
			}else{
				$actions=$_POST['actions'];
				$condition.="  类型:‘".$actions."’";
			}
			
			if (strlen($_POST['confirm'])==0){
				$confirm=NULL;
			}else{
				$confirm=$_POST['confirm'];
				$condition.="  状态:‘".$confirm."’";
			}
			
			if (strlen($_POST['fromYear'])!=4&&strlen($_POST['fromMonth'])!=2&&strlen($_POST['fromDate'])!=2){
				$start=NULL;
			}else{
				$start=$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate'];
				$condition.="  时间从:".$start;
				
			}
			if (strlen($_POST['toYear'])!=4&&strlen($_POST['toMonth'])!=2&&strlen($_POST['toDate'])!=2){
				$end=NULL;
			}else{
				$end=$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate'];
				$condition.="  时间至:".$end;
				
			}
			
			if (strlen($_POST['minNum'])==0||!is_numeric($_POST['minNum'])){
				$minNum=NULL;
			}else{
				$minNum=$_POST['minNum'];
				$condition.="  数量下限:".$minNum;
			}
			if (strlen($_POST['maxNum'])==0||!is_numeric($_POST['maxNum'])){
				$maxNum=NULL;
			}else{
				$maxNum=$_POST['maxNum'];
				$condition.="  数量上限:".$maxNum;
			}
			if($condition==""){
				$condition="无";
			}

			$minimal=NULL;
			$maximal=NULL;
			
			
			
		   $organization=$this->model->getOrganizations($_GET['id']);
		   $transactions=$this->model->getFinacialTransactions($actions,$_GET['id'],$start,$end,$minimal,$maximal,$minNum,$maxNum,$scan_code,$confirm);
		 
		   $table=transactionToTable($transactions,$organization->id,$organization->name,NULL);
		   $message="物流记录搜索 得到(".count($transactions).")条记录 条件为：\n";
		   $organization->setTransactions($transactions);
		 
			include 'view/organization_transaction.php';
	        break;
	    case 'organization_sell_record':
	        $condition="";
			if(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_org_by_date_amount'){
				runtimelog( "entered _s_report_daterange_org_by_date_amount");
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate,$_GET['id']);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure('_s_report_daterange_org_by_date',$para);
				include 'view/organization_sell_record2.php';
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_org_by_date_number'){
				runtimelog( "entered _s_report_daterange_org_by_date_number");
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate,$_GET['id']);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure('_s_report_daterange_org_by_date',$para);
				include 'view/organization_sell_record1.php';
			}else{
				
			
				
				if (!isset($_POST['scan_code'])||strlen($_POST['scan_code'])!=14){
					$scan_code=NULL;
				}else{
					$scan_code=$_POST['scan_code'];
					$condition.="  条形码为:".$scan_code;
				}
				
				if (!isset($_POST['fromYear'])||strlen($_POST['fromYear'])!=4||strlen($_POST['fromMonth'])!=2||strlen($_POST['fromDate'])!=2){
					$start=NULL;
				}else{
					$start=$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate'];
					$condition.="  时间从:".$start;
					
				}
				if (!isset($_POST['toYear'])||strlen($_POST['toYear'])!=4||strlen($_POST['toMonth'])!=2||strlen($_POST['toDate'])!=2){
					$end=NULL;
				}else{
					$end=$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate'];
					$condition.="  时间至:".$end;
					
				}
				
				if (!isset($_POST['minimal'])||strlen($_POST['minimal'])==0||!is_numeric($_POST['minimal'])){
					$minimal=NULL;
				}else{
					$minimal=$_POST['minimal'];
					$condition.="  金额下限限:".$minimal;
				}
				if (!isset($_POST['maximal'])||strlen($_POST['maximal'])==0||!is_numeric($_POST['maximal'])){
					$maximal=NULL;
				}else{
					$maximal=$_POST['maximal'];
					$condition.="  金额上限:".$maximal;
				}
				if($condition==""){
					$condition="无";
				}
				$actions=array('sell','return');
				$minNum=NULL;
				$maxNum=NULL;
            	$confirm=array(0,1);
			   	$organization=$this->model->getOrganizations($_GET['id']);
							
			   	$transactions=$this->model->getFinacialTransactions($actions,$_GET['id'],$start,$end,$minimal,$maximal,$minNum,$maxNum,$scan_code,$confirm);
			  	include 'view/displayTable.php';
				$table=financialTransactionToTable($transactions,$organization->id,$organization->name);
			   	$message="销售记录搜索 得到(".count($transactions).")条记录 条件为：\n";
			   	$organization->setTransactions($transactions);
			  	include 'view/organization_sell_record.php';
			  }
	        break;
	    case 'organization_distribute_confirm':
	        $organization=$this->model->getOrganizations($_GET['id']);
			
		   $pendingTransactions=$this->model->getPendingTransactionsByOrid($_GET['id']);
		   
		   $organization->setTransactions($pendingTransactions);
		    include 'view/displayTable.php';

			$table=transactionToTable($pendingTransactions,$organization->id,$organization->name,'checkbox');
			include 'view/organization_distribute_confirm.php';
	        break;
	    case 'organization_distribute':
	         $organization=$this->model->getOrganizations($_GET['id']);
		   	 $inventory=$this->model->getInventory($_GET['id']);
		   	 $organization->setInventory($inventory);
		 		include 'view/displayTable.php';

			$table=inventoryToTable($inventory,$organization->id,$organization->name,'radio');
			include 'view/organization_distribute.php';
	        break;
	    case 'organization_sell':
			$organization=$this->model->getOrganizations($_GET['id']);
		    $inventory=$this->model->getInventory($_GET['id']);
		    $organization->setInventory($inventory);
		    include 'view/displayTable.php';

			$table=inventoryToTable($inventory,$organization->id,$organization->name,'radio');
			include 'view/organization_sell.php';
	        break;
		case 'accounting_report':
		if($currentUser->authrized('accounting')){
			$reportName=$this->model->getReportName();
			print_r($reportName);
			include 'view/accounting_report.php';
			}else{
			include 'view/home.php';
			}
			break;
		case 'accounting_inventory':
			include 'view/displayTable.php';
            $temp=array();
		
		    $condition="";
			if (!isset($_POST['orid'])||$_POST['orid']==""){
				$orid=NULL;
			}else{
				$orid=$_POST['orid'];	
				$condition.="  机构代号:".$orid;
				
			}
			if (strlen($_POST['scan_code'])!=14){
				$scan_code=NULL;	
				
			}else{
				$scan_code=$_POST['scan_code'];
				$condition.="  条形码为:".$scan_code;
			}
			
			$start=NULL;
			$end=NULL;
			
			
			if (!isset($_POST['minNum'])||strlen($_POST['minNum'])==0||!is_numeric($_POST['minNum'])){
				$minNum=NULL;
			}else{
				$minNum=$_POST['minNum'];
				$condition.="  数量下限:".$minNum;
			}
			if (!isset($_POST['maxNum'])||strlen($_POST['maxNum'])==0||!is_numeric($_POST['maxNum'])){
				$maxNum=NULL;
			}else{
				$maxNum=$_POST['maxNum'];
				$condition.="  数量上限:".$maxNum;
			}
			if($condition==""){
				$condition="无";
			}
		   	$inventory=$this->model->getInventory($orid,$scan_code,$minNum,$maxNum,$start,$end);
		    $message="库存搜索 得到(".count($inventory).")条记录 条件为：\n";
			
			$table=inventoryToTable($inventory,'total','菲雪洛琳','total');
			
			include 'view/accounting_inventory.php';
	        break;
	     case 'accounting_sell_record':
			 if($currentUser->authrized('accounting')){
			$condition="";
			 $option="";
			if(!isset($_POST['option'])||$_POST['option']=='_s_report_daterange_by_date'){
				$option='_s_report_daterange_by_date';
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure($option,$para);
				$option='_s_report_daterange_by_date';
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_by_month'){
				$option='_s_report_daterange_by_month';
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure($option,$para);
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_by_org'){
				$option='_s_report_daterange_by_org';
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure($option,$para);
					include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_by_productcode'){
				$option='_s_report_daterange_by_productcode';
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure($option,$para);
							include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
				
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_daterange_by_scancode'){
				$option='_s_report_daterange_by_scancode';
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$para=array($startdate,$enddate);
				$message="销售记录搜索 条件为：\n";
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
				$lineCurve=$this->model->storedProcedure($option,$para);
							include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
				
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_monthyear_by_org'){
				$option='_s_report_monthyear_by_org';
				$targetyear=isset($_POST['targetYear'])?$_POST['targetYear']:date('Y');
				$targetmonth=isset($_POST['targetMonth'])?$_POST['targetMonth']:date('m');
				$para=array($targetmonth,$targetyear);
				$message="销售记录搜索 条件为：\n";
				$condition="目标月份".$targetmonth."/".$targetyear;
				$lineCurve=$this->model->storedProcedure($option,$para);
							include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_monthyear_by_productcode'){
				$option='_s_report_monthyear_by_productcode';
				$targetyear=isset($_POST['targetYear'])?$_POST['targetYear']:date('Y');
				$targetmonth=isset($_POST['targetMonth'])?$_POST['targetMonth']:date('m');
				$para=array($targetmonth,$targetyear);
				$message="销售记录搜索 条件为：\n";
				$condition="目标月份".$targetmonth."/".$targetyear;
				$lineCurve=$this->model->storedProcedure($option,$para);
							include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
			}elseif(isset($_POST['option'])&&$_POST['option']=='_s_report_monthyear_by_scancode'){
				$option='_s_report_monthyear_by_scancode';
				$targetyear=isset($_POST['targetYear'])?$_POST['targetYear']:date('Y');
				$targetmonth=isset($_POST['targetMonth'])?$_POST['targetMonth']:date('m');
				$para=array($targetmonth,$targetyear);
				$message="销售统计搜索 条件为：\n";
				$condition="目标月份".$targetmonth."/".$targetyear;
				$lineCurve=$this->model->storedProcedure($option,$para);
							include 'view/displayTable.php';
				$table=databaseToTable($lineCurve,$option);
			}elseif(isset($_POST['option'])&&$_POST['option']=='_detail_report'){
				$option='_detail_report';
				$actions=array('sell','return');
				$startdate=isset($_POST['fromYear'])?$_POST['fromYear'].'-'.$_POST['fromMonth'].'-'.$_POST['fromDate']:'2000-01-01';
				$enddate=isset($_POST['toYear'])?$_POST['toYear'].'-'.$_POST['toMonth'].'-'.$_POST['toDate']:date('Y-m-d');
				$transactions=$this->model->getFinacialTransactions($actions,NULL,$startdate,$enddate,NULL,NULL,NULL,NULL,NULL,1);
			  	include 'view/displayTable.php';
				$table=financialTransactionToTable($transactions,$organization->id,$organization->name);
			   	$message="销售统计搜索 得到(".count($transactions).")条记录 条件为：\n";				
				$condition="起始时间:".$startdate." 结束时间 ".$enddate;
			}
			include 'view/accounting_sell_record.php';
			}else{
			include 'view/home.php';			
			}
	        break;
		case 'accounting_distributing':
			if($currentUser->authrized('accounting')){
			//include 'view/accounting_distributing.php';
				$option='_inv_distributing';
				$para=array();
				$message="销售统计搜索 条件为：\n";
				$condition="目标月份";
				$lineCurve=$this->model->storedProcedure($option,$para);
				include 'view/displayTable.php';
				$table=databaseToTableDistributing($lineCurve);
				include 'view/accounting_distributing.php';
			}else{
			include 'view/home.php';			
			}
	        break;
		case 'intro_scan_code':
			include 'view/intro_scan_code.php';
	        break;
		default: 
			include 'view/home.php';
			 break;						
	        }
		include 'view/viewbodyend.php';
	  }
	}

}

?>